 
$(document).ready(function() {
	var host = "ws://localhost:8080/im/realtime";

	if ("WebSocket" in window) {
		var es = new EventSocket(host); 
		
		es.on("publish",function(data){
			var title = '<a href="#">洪磊明</a><span>[19:14]</span>';
			var msg = "<li>"+title+"<p>" + data.body + "</p></li>";
			$("#msgs").append(msg);  
			$("#room").prop({ scrollTop: $("#room").prop("scrollHeight") });
		});
		
		$("input[type=button]").click(function() {
			var value = $('#data').val();;
			es.emit('publish',{'body':value});
			$("#data").val('');
		});
	} else {
		alert("WebSocket not supported");
	}
	$("#room").prop({ scrollTop: $("#room").prop("scrollHeight") });
});